<div id="page_content">
    <h2><?= $this->t->_('View records') ?></h2>

    <?php if (!is_null($this->records) && count($this->records) > 0) { ?>
        <?= $this->t->_("Search") ?>: <input name="filter" id="sortable-filter-box" value="" maxlength="30" size="30" type="text">
        <input id="sortable-filter-clear-button" type="submit" value="<?= $this->t->_("Clear") ?>"/>
        <?
        echo '<table class="sortable"><thead><tr>';
        foreach ($this->fields as $f)
            if ($f->visible > 0)
                echo '<th>' . $f->title . '</th>';
        echo '</tr></thead>';
        foreach ($this->records as $r) {
            echo '<tr>';
            foreach ($this->fields as $f) {
                $field = $f->field;
                $add = '';
                if ($f->type == 'image')
                    $add = 'class="imgpreview" rel="' . $r->$field . '"';
                if ($f->visible)
                    echo '<td><a href="' . ADMIN_URL . '/pages/modify/a/record/rid/' . $this->ref['id'] . '/id/' . $r->sid . '/recid/' . $r->id . '" ' . $add . '>' . $r->$field . '</td>';
            }
            echo '</tr>';
        }
        echo '</table>';
        ?>
        <div id="sortablepager" class="clearfix pager"> 
            <form> 
                <a href="#" class="first" title="<?= $this->t->_("First") ?>"><span><?= $this->t->_("First") ?></span></a>
                <a href="#" class="prev" title="<?= $this->t->_("Previous") ?>"><span><?= $this->t->_("Previous") ?></span></a>
                <span class="pagedisplay"></span>
                <a href="#" class="next" title="<?= $this->t->_("Next") ?>"><span><?= $this->t->_("Next") ?></span></a>
                <a href="#" class="last" title="<?= $this->t->_("Last") ?>"><span><?= $this->t->_("Last") ?></span></a>
                <select class="pagesize"> 
                    <option value="<?= $this->ref['count'] ?>"><?= $this->ref['count'] ?></option>
                    <option selected="selected" value="10">10</option>
                    <option value="20">20</option> 
                    <option value="50">50</option> 
                    <option value="100">100</option> 
                </select> 
            </form> 
        </div> 

        <?php
    } else {
        if (is_null($this->records))
            echo '<p>' . $this->t->_('Error query') . '</p>';    
        else 
            echo '<p>' . $this->t->_('No records') . '</p>';
    }
    ?>

    <h2><?= $this->t->_('Reference'); ?></h2>
    <?= $this->form; ?>
</div>

<?php if (isset($this->ref)) { ?>
    <div id="sidebar">
        <a href="<?= ADMIN_URL . '/pages/modify/a/record/rid/' . $this->ref['id'] . '/id/' . $this->section->id ?>" class="sidebar_button add_button"><?= $this->t->_("New record") ?></a>
    </div>
<?php } ?>
